package com.lqjava.flowable.beans.mapper.common;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * mybatis 公共mapper
 * @param <T> 实体类型
 * @author lq 2021年3月21日 18:35:33
 */
public interface ICRUDMapper<T> extends BaseMapper<T> {

    @Select("select ${cols} from ${table} ${ew.customSqlSegment}")
    public List<T> execSql2SelectList(@Param("table") String table,@Param("cols") String cols,@Param(Constants.WRAPPER) Wrapper<T> wrapper);

    @Select("select ${cols} from ${table} ${ew.customSqlSegment}")
    public T execSql2SelectOne(@Param("table") String table,@Param("cols") String cols,@Param(Constants.WRAPPER) Wrapper<T> wrapper);

    @Insert("insert into ${table} ${cols} values ${values}")
    public int execSql2Insert(@Param("table") String table,@Param("cols") String cols,@Param("values") String values);

    @Update("update ${table} set ${set} ${ew.customSqlSegment}")
    public int execSql2Update(@Param("table") String table,@Param("set") String set,@Param(Constants.WRAPPER) Wrapper<T> wrapper);

    @Update("delete from  ${table} ${ew.customSqlSegment}")
    public int execSql2Delete(@Param("table") String table,@Param(Constants.WRAPPER) Wrapper<T> wrapper);
}
